package com.ibeetl.codestory.core.ast;

import com.ibeetl.codestory.core.ctx.Context;

import java.util.List;

public abstract class Ast {
	protected  Token token;
	protected List<Ast> children;
	protected Ast parent;
	protected AstType  astType = null;
	public Ast(Token token){
		this.token = token;

	}

	public void visit(Context ctx){
		ctx.onAction(this);
		if(children==null){
			return ;
		}
		for(Ast ast:children){
			ast.visit(ctx);
		}
	}


	public Token getToken() {
		return token;
	}

	public List<Ast> getChildren() {
		return children;
	}

	public AstType getAstType() {
		return astType;
	}

	public Ast getParent() {
		return parent;
	}

	public void setParent(Ast parent) {
		this.parent = parent;
	}
}
